
$(document).ready(function () {
	initDate();
});

function initDate(){
	$('.form_date').datetimepicker({
	    language:  'zh-CN',
	    weekStart: 1,
	    todayBtn:  1,
	    autoclose: 1,
	    todayHighlight: 1,
	    startView: 2,
	    minView: 2,
	    forceParse: 0,
	    dateFormat: 'yyyy-mm-dd',
	    defaultDate : "2015-12-12"
	});
}

var editor;
KindEditor.ready(function(K) {
	editor = K.create('textarea[name="content"]', {
		resizeType : 1,
		allowPreviewEmoticons : false,
		allowImageUpload : false,
		afterBlur : function(){  
            //编辑器失去焦点时直接同步，可以取到值  
            this.sync();  
        }  
	});
});

//完成注册页面
function doAdd() {
	if(!$( "#addHomework" ).validate({
		rules: {
			title: "required"
		},
		messages: {
			title: "<font color='red'>请输入作业标题</font>"
	      }
	}).form()) return false;
	
	$.ajax({
        type: "POST",
        url: ctx+"/study/homework/doAdd",
        data: $("#addHomework").serialize(),
        dataType: "json",
        success: function(data){
        	if(data.statusCode==1){
        		alert("发布成功");
        		window.parent.reloadTabGrid("我的发布");
        		window.parent.removeTab();
        	}else{
        		alert(data.message)
        	}
        }
    });
}

